/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.NVGH;

import DAO.CTPXuatKhoDao;
import DAO.HoaDonDao;
import DAO.PXuatKhoDao;
import DAO.SanPhamDao;
import GUI.Var;
import POJO.CTPXuatKho;
import POJO.KhachHang;
import POJO.PXuatKho;
import POJO.SanPham;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Khoi
 */
public class frXemPhieuXuatKho extends javax.swing.JInternalFrame {

	/**
	 * Creates new form frXemPhieuXuatKho
	 */
	DefaultTableModel tbModel1;
	DefaultTableModel tbModel2;
	ArrayList<KhachHang> DSKH = new ArrayList<KhachHang>();// bien khai bao chua su dung
	private int TSD;// tong so dong trong bang hoa don
	private int THT = 0; //trang hiện tại
	private int SD = 20;// hien thi bao nhieu dong tron trang

	public frXemPhieuXuatKho() {
		initComponents();
		lbNVDN.setText(Var.NV.getTenNV());
		tbModel1 = new DefaultTableModel();
		tbModel2 = new DefaultTableModel();
		TSD = soDongDuLieu();
		loadDSPX(SD, THT);
		setTxt();

	}

	private int soDongDuLieu() {
		int tmp = 0;
		PXuatKhoDao dao = new PXuatKhoDao();
		try {
			tmp = dao.laySoDong(Var.NV.getMaNV());
		} catch (Exception e) {
		}
		return tmp;
	}

	private void DefaultDSPX() {// danh sách phiếu xuất

		tbModel1 = new DefaultTableModel();
		//tạo các cột
		this.tbModel1.addColumn("Số PX ");
		this.tbModel1.addColumn("Ngày xuất");
		this.tbModel1.addColumn("Số hóa đơn");

		this.tbModel1.addColumn("Khách hàng");
		
		tbDanhSach.setModel(tbModel1);
		// Canh deu cac dong theo ti le % 10 % 30% 20%
		int[] va = {20, 20, 20, 40};
		int[] pt = new int[4];
		for (int l = 0; l < 4; l++) {
			pt[l] = tbDanhSach.getWidth() * va[l] / 100;
			tbDanhSach.getColumnModel().getColumn(l).setPreferredWidth(pt[l]);

		}
	}

	private void DefaultCTPX() {// chi tiết phiếu xuất

		tbModel2 = new DefaultTableModel();
		//tạo các cột
		this.tbModel2.addColumn("STT ");
		this.tbModel2.addColumn("Mã sản phẩm ");
		this.tbModel2.addColumn("Sản phẩm");
		this.tbModel2.addColumn("Số lượng ");
		
		tbChiTiet.setModel(tbModel2);
		// Canh deu cac dong theo ti le % 
		int[] va = {20, 20, 40, 20};
		int[] pt = new int[4];
		for (int l = 0; l < 4; l++) {
			pt[l] = tbChiTiet.getWidth() * va[l] / 100;
			tbChiTiet.getColumnModel().getColumn(l).setPreferredWidth(pt[l]);

		}
	}

	private void loadDSPX(int soDong, int trangSo) { // load danh sách phiếu xuất theo nhân viên đăng nhập
		DefaultDSPX();
		ArrayList<PXuatKho> ds = new ArrayList<PXuatKho>();
		HoaDonDao hd = new HoaDonDao();
		try {
			ds = PXuatKhoDao.layDanhSachByNhanVienPhanTrang(Var.NV.getMaNV(), soDong, trangSo);
		} catch (Exception e) {
		}
		int i = 1;
		for (PXuatKho ob : ds) {
			KhachHang kh = new KhachHang();
			kh = hd.layKhachHangByMaHoaDon(ob.getMaHD());

			Object[] items = new Object[]{
				ob.getMaPXK(),
				Var.hienThiNgayVN(ob.getNgayXuat()),
				ob.getMaHD(),// mã hóa đơn
				kh.getTenKH()
			};
			i++;
			//int maLSP = sp.getMaLSP();
			tbModel1.addRow(items);
		}
		
		if (tbModel1.getRowCount() > 0) {
			loadThongTinPhieuXuat(0);
		}
	}

	private void loadThongTinPhieuXuat(int vt) {
		int mpx = (Integer) tbModel1.getValueAt(vt, 0);
		String ng = (String) tbModel1.getValueAt(vt, 1);
		String k = (String) tbModel1.getValueAt(vt, 3);
		txSoPX.setText(Integer.toString(mpx));
		txNgayXuat.setText(ng.toString());
		txTenKH.setText(k);

		loadCTPX(mpx);
	}

	private void loadCTPX(int MaPX) { // load danh sách phiếu xuất theo nhân viên đăng nhập
		DefaultCTPX();
		ArrayList<CTPXuatKho> ds = new ArrayList<CTPXuatKho>();
		CTPXuatKhoDao ct = new CTPXuatKhoDao();
		SanPhamDao spd = new SanPhamDao();
		try {
			ds = CTPXuatKhoDao.layDanhSachByMaPX(MaPX);
		} catch (Exception e) {
		}
		int i = 1;
		for (CTPXuatKho ob : ds) {
			SanPham sp = new SanPham();
			sp = spd.LaySanPhamByMa(ob.getMaSP());
			Object[] items = new Object[]{
				i,
				ob.getMaSP(),
				sp.getTenSP(),
				ob.getSoLuong()
			};
			i++;
			//int maLSP = sp.getMaLSP();
			tbModel2.addRow(items);
		}
		
	}

	/**
	 * This method is called from within the constructor to initialize the
	 * form. WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
       // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
       private void initComponents() {

              jPanel3 = new javax.swing.JPanel();
              jPanel4 = new javax.swing.JPanel();
              jScrollPane2 = new javax.swing.JScrollPane();
              tbDanhSach = new javax.swing.JTable();
              lbNVDN = new javax.swing.JLabel();
              jLabel5 = new javax.swing.JLabel();
              jPanel11 = new javax.swing.JPanel();
              jButton10 = new javax.swing.JButton();
              jButton11 = new javax.swing.JButton();
              jButton12 = new javax.swing.JButton();
              jButton13 = new javax.swing.JButton();
              lbPhanTrang = new javax.swing.JLabel();
              jPanel6 = new javax.swing.JPanel();
              jPanel8 = new javax.swing.JPanel();
              jLabel2 = new javax.swing.JLabel();
              txSoPX = new javax.swing.JTextField();
              jLabel3 = new javax.swing.JLabel();
              txNgayXuat = new javax.swing.JTextField();
              jLabel4 = new javax.swing.JLabel();
              txTenKH = new javax.swing.JTextField();
              jPanel7 = new javax.swing.JPanel();
              jScrollPane1 = new javax.swing.JScrollPane();
              tbChiTiet = new javax.swing.JTable();
              jPanel1 = new javax.swing.JPanel();
              jLabel1 = new javax.swing.JLabel();
              jPanel5 = new javax.swing.JPanel();
              jButton1 = new javax.swing.JButton();

              setClosable(true);
              setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
              setIconifiable(true);
              setMaximizable(true);
              setResizable(true);

              jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách phiếu xuất"));
              jPanel4.setToolTipText("");

              tbDanhSach.setModel(new javax.swing.table.DefaultTableModel(
                     new Object [][] {
                            {null, null, null, null},
                            {null, null, null, null},
                            {null, null, null, null},
                            {null, null, null, null}
                     },
                     new String [] {
                            "Số phiếu xuất", "Ngày xuất", "Số hóa đơn", "Khách hàng"
                     }
              ));
              tbDanhSach.addMouseListener(new java.awt.event.MouseAdapter() {
                     public void mouseClicked(java.awt.event.MouseEvent evt) {
                            tbDanhSachMouseClicked(evt);
                     }
              });
              jScrollPane2.setViewportView(tbDanhSach);

              lbNVDN.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
              lbNVDN.setText("[Nhân viên đăng nhập]");

              jLabel5.setText("Tên nhân viên:");

              jButton10.setText("|<");
              jButton10.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jButton10ActionPerformed(evt);
                     }
              });

              jButton11.setText("<");
              jButton11.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jButton11ActionPerformed(evt);
                     }
              });

              jButton12.setText(">|");
              jButton12.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jButton12ActionPerformed(evt);
                     }
              });

              jButton13.setText(">");
              jButton13.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jButton13ActionPerformed(evt);
                     }
              });

              lbPhanTrang.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
              lbPhanTrang.setText("0");

              javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
              jPanel11.setLayout(jPanel11Layout);
              jPanel11Layout.setHorizontalGroup(
                     jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel11Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton10)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton11)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lbPhanTrang)
                            .addGap(24, 24, 24)
                            .addComponent(jButton13)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton12)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel11Layout.setVerticalGroup(
                     jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jButton10)
                                   .addComponent(jButton11)
                                   .addComponent(jButton12)
                                   .addComponent(jButton13)
                                   .addComponent(lbPhanTrang)))
              );

              javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
              jPanel4.setLayout(jPanel4Layout);
              jPanel4Layout.setHorizontalGroup(
                     jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel4Layout.createSequentialGroup()
                            .addGap(42, 42, 42)
                            .addComponent(jLabel5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lbNVDN)
                            .addContainerGap())
                     .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)
                     .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              );
              jPanel4Layout.setVerticalGroup(
                     jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(lbNVDN)
                                   .addComponent(jLabel5))
                            .addGap(18, 18, 18)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              );

              jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin phiếu xuất kho"));

              jLabel2.setText("Số phiếu xuất kho:");

              txSoPX.setEnabled(false);

              jLabel3.setText("Ngày xuất:");

              txNgayXuat.setEnabled(false);

              jLabel4.setText("Khách hàng:");

              txTenKH.setEnabled(false);

              javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
              jPanel8.setLayout(jPanel8Layout);
              jPanel8Layout.setHorizontalGroup(
                     jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel8Layout.createSequentialGroup()
                            .addGap(60, 60, 60)
                            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                   .addGroup(jPanel8Layout.createSequentialGroup()
                                          .addComponent(jLabel4)
                                          .addGap(18, 18, 18)
                                          .addComponent(txTenKH, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                                   .addGroup(jPanel8Layout.createSequentialGroup()
                                          .addComponent(jLabel3)
                                          .addGap(18, 18, 18)
                                          .addComponent(txNgayXuat, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                                   .addGroup(jPanel8Layout.createSequentialGroup()
                                          .addComponent(jLabel2)
                                          .addGap(18, 18, 18)
                                          .addComponent(txSoPX, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(30, Short.MAX_VALUE))
              );
              jPanel8Layout.setVerticalGroup(
                     jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel8Layout.createSequentialGroup()
                            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jLabel2)
                                   .addComponent(txSoPX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jLabel3)
                                   .addComponent(txNgayXuat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jLabel4)
                                   .addComponent(txTenKH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 0, Short.MAX_VALUE))
              );

              jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Chi tiết phiếu nhập kho"));

              tbChiTiet.setModel(new javax.swing.table.DefaultTableModel(
                     new Object [][] {
                            {null, null, null, null},
                            {null, null, null, null},
                            {null, null, null, null},
                            {null, null, null, null}
                     },
                     new String [] {
                            "STT", "Mã sản phẩm", "Sản phẩm", "Số lượng"
                     }
              ));
              jScrollPane1.setViewportView(tbChiTiet);

              javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
              jPanel7.setLayout(jPanel7Layout);
              jPanel7Layout.setHorizontalGroup(
                     jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
              );
              jPanel7Layout.setVerticalGroup(
                     jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE)
              );

              javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
              jPanel6.setLayout(jPanel6Layout);
              jPanel6Layout.setHorizontalGroup(
                     jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                     .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              );
              jPanel6Layout.setVerticalGroup(
                     jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel6Layout.createSequentialGroup()
                            .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );

              javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
              jPanel3.setLayout(jPanel3Layout);
              jPanel3Layout.setHorizontalGroup(
                     jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel3Layout.setVerticalGroup(
                     jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                     .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              );

              jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
              jLabel1.setText("XEM PHIẾU XUẤT KHO (của nhân viên đang đăng nhập)");

              javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
              jPanel1.setLayout(jPanel1Layout);
              jPanel1Layout.setHorizontalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel1)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel1Layout.setVerticalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addGap(0, 0, Short.MAX_VALUE))
              );

              jButton1.setText("Hiển thị");
              jButton1.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jButton1ActionPerformed(evt);
                     }
              });

              javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
              jPanel5.setLayout(jPanel5Layout);
              jPanel5Layout.setHorizontalGroup(
                     jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton1)
                            .addGap(248, 248, 248))
              );
              jPanel5Layout.setVerticalGroup(
                     jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel5Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(jButton1))
              );

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
              getContentPane().setLayout(layout);
              layout.setHorizontalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(0, 0, 0))
              );
              layout.setVerticalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0))
              );

              pack();
       }// </editor-fold>//GEN-END:initComponents

       private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
		// TODO add your handling code here:
		loadDSPX(SD, THT);
       }//GEN-LAST:event_jButton1ActionPerformed

       private void tbDanhSachMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDanhSachMouseClicked
		// TODO add your handling code here:
		int vt = tbDanhSach.getSelectedRow();
		if (vt > 0) {
			loadThongTinPhieuXuat(vt);
		}
       }//GEN-LAST:event_tbDanhSachMouseClicked
	private void setTxt() {
		lbPhanTrang.setText(Integer.toString(THT + 1) + "/" + Integer.toString(TSD / SD + 1));
	}
       private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
		// TODO add your handling code here:
		// ve dau tien
		THT = 0;
		loadDSPX(SD, THT);
		setTxt();

       }//GEN-LAST:event_jButton10ActionPerformed

       private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
		// TODO add your handling code here:
		//ve trang truoc
		if (THT != 0) {
			THT -= 1;
			loadDSPX(SD, THT);
		}
		setTxt();

       }//GEN-LAST:event_jButton11ActionPerformed

       private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
		// TODO add your handling code here:
		// ve cuoi

		THT = TSD / SD;
		loadDSPX(SD, THT);

		setTxt();

       }//GEN-LAST:event_jButton12ActionPerformed

       private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
		// TODO add your handling code here:
		if (THT < TSD / SD) {
			THT += 1;
			loadDSPX(SD, THT);
		}
		setTxt();

       }//GEN-LAST:event_jButton13ActionPerformed


       // Variables declaration - do not modify//GEN-BEGIN:variables
       private javax.swing.JButton jButton1;
       private javax.swing.JButton jButton10;
       private javax.swing.JButton jButton11;
       private javax.swing.JButton jButton12;
       private javax.swing.JButton jButton13;
       private javax.swing.JLabel jLabel1;
       private javax.swing.JLabel jLabel2;
       private javax.swing.JLabel jLabel3;
       private javax.swing.JLabel jLabel4;
       private javax.swing.JLabel jLabel5;
       private javax.swing.JPanel jPanel1;
       private javax.swing.JPanel jPanel11;
       private javax.swing.JPanel jPanel3;
       private javax.swing.JPanel jPanel4;
       private javax.swing.JPanel jPanel5;
       private javax.swing.JPanel jPanel6;
       private javax.swing.JPanel jPanel7;
       private javax.swing.JPanel jPanel8;
       private javax.swing.JScrollPane jScrollPane1;
       private javax.swing.JScrollPane jScrollPane2;
       private javax.swing.JLabel lbNVDN;
       private javax.swing.JLabel lbPhanTrang;
       private javax.swing.JTable tbChiTiet;
       private javax.swing.JTable tbDanhSach;
       private javax.swing.JTextField txNgayXuat;
       private javax.swing.JTextField txSoPX;
       private javax.swing.JTextField txTenKH;
       // End of variables declaration//GEN-END:variables
}
